<?php
class RegisterForm extends Zend_Form {
    public function __construct($options = null) 
    {
    	$baseurl 		= new MHDEV_View_Helper_BaseUrl();
    	$translation	= Zend_Registry::get('lang');
    	
        parent::__construct($options);
        
        $this->setName('register');
        
        // Username
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel($translation->_('register_username'));
        $username->setRequired(true);
        $username->addFilter('StringTrim');
        $username->addFilter('StripTags');
        $username->setErrorMessages(array(
            0 => $translation->_('error_register_username'),
        ));
        $username->setDescription($translation->_('register_dusername'));
        
        
        // Mail
        $mail = new Zend_Form_Element_Text('mail');
        $mail->setLabel($translation->_('register_mail'));
        $mail->setRequired(true);
        $mail->addFilter('StringToLower');
        $mail->addFilter('StringTrim');
        $mail->addFilter('StripTags');
        $mail->setErrorMessages(array(
            0 => $translation->_('error_register_mail'),
        ));
        $mail->setDescription($translation->_('register_dmail'));
        $mail->addValidator('EmailAddress');

        // Password
        $password = new Zend_Form_Element_Password('password');
		$password->setLabel($translation->_('register_password'));
		$password->setRequired(true);
		$password->addFilter('StringTrim');
		$password->addValidator('NotEmpty', true);
		$password->addValidator('StringLength', true, array(6,20));
		$password->setErrorMessages(array(
            'isEmpty' => $translation->_('error_register_password'),
			'stringLengthTooShort' 	=> $translation->_('error_register_password_2'),
            'stringLengthTooLong'	=> $translation->_('error_register_password_3'),
        ));
        $password->setDescription($translation->_('register_dpassword'));

        // language
        $language = new Zend_Form_Element_Select('language');
        $language->setLabel($translation->_('register_language'));
        $language->setDescription($translation->_('register_dlanguage'));
        $language->addMultiOption('en', 'English');
        $language->addMultiOption('de', 'German');
        
        // captcha 
        $captcha = new Zend_Form_Element_Captcha('captcha', array(
            'label' => $translation->_('captcha'),
            'captcha' => array(
                'captcha' => 'Image',
                'wordLen' => 6,
                'timeout' => 300,
                'width' => 200,
                'heigth' => 150,
                'imgDir' => 'static/gfx/captcha/',
                'imgUrl' => $baseurl->BaseUrl() . '/static/gfx/captcha/',
                'font' => 'static/gfx/captcha/fonts/gautami.ttf',
                'fontsize' => 28,
        		'messages' => array(
                    'badCaptcha' => $translation->_('error_captcha'),
                    'missingID' => $translation->_('error_captcha'),
                    'missingValue' => $translation->_('error_captcha')
                )
            )
        ));
        $captcha->setDescription($translation->_('captcha_desc'));
        
        // Submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel($translation->_('form_save'));

        $this->addElements(array($username, $mail, $password, $language, $captcha, $submit));
    }
}  
?>